﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataAccessLayer
{
    public class PurchaseOrderDetailRepository
    {
        StationeryInventoryEntities1 ent;

        public PurchaseOrderDetailRepository()
        {
            ent = new StationeryInventoryEntities1();
        }

        #region Select Method
        public List<PurchaseOrderDetail> GetPurchaseOrderDetailByPOId(int poId)
        {
            List<PurchaseOrderDetail> list = new List<PurchaseOrderDetail>();

            var poDetail = ent.PurchaseOrderDetails.Where(x => x.POID == poId);

            if (poDetail != null)
            {
                list = poDetail.ToList();
            }
            return list;
        }
        #endregion

        #region Create Method
        public void CreatePurchaseOrderDetail(PurchaseOrderDetail purchaseOrderDetail)
        {
            ent.PurchaseOrderDetails.Add(purchaseOrderDetail);
            ent.SaveChanges();
        }
        #endregion
    }
}
